package com.maoye.ossp.sys.auth.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.maoye.ossp.common.web.BaseController;
import com.maoye.ossp.sys.auth.service.ISysAuthPermissionService;
import com.maoye.ossp.sys.org.util.UserUtils;
import com.maoye.sc.api.domain.Subsystem;

/**
 * 权限Contorller
 * 
 * @author zhuangwl
 * 
 *         2014年6月7日
 */
@Controller
@RequestMapping(value = "sys/auth/")
public class PermissionController extends BaseController {

	@Resource
	private ISysAuthPermissionService sysAuthPermissionService;

	/**
	 * 初始化系统权限
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "showPermission")
	public String showPermission(Model model) throws Exception {
		// 获取该机构配置好的系统资源
		List<Subsystem> subsysList = sysAuthPermissionService
				.getOrgConfigSubsystem(UserUtils.getOrgId());
		model.addAttribute("subsysList", subsysList);
		return "/sys/auth/initPage";
	}

	/**
	 * 初始化系统权限
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "initPermissionData")
	public String initPermissionData(Model model) throws Exception {
		sysAuthPermissionService.initPermissionData();
		return SUCCESS;
	}

}
